<script lang="ts" setup>
import { Swiper, SwiperSlide } from 'swiper/vue'
import { Navigation } from "swiper"
import { ref } from 'vue'
import router from "@/router";
import 'swiper/css'
import 'swiper/css/pagination'

const modules = ref([Navigation])
const caseList = ref() as any

const props = defineProps({
    caseData: Array
})
caseList.value = props.caseData

const LearnDatas = (id: number) => {
    router.push({
        path: '/NewsDetail',
        query: {
            id: id,
        },
    });
};

</script>

<template>
    <div class="custom-box">
        <swiper class="swiper" :modules="modules" :slides-per-view="1" :free-mode="true" :loop="true"
            :pagination="{ clickable: true }" :navigation="{
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            }">
            <swiper-slide class="slide" v-for="item in caseList" :key="item.id">
                <el-row>
                    <el-col :span="12">
                        <div class="case-left">
                            <div class="auxiliaryText time">{{ item.created_at?.slice(0, 10) }}</div>
                            <div class="secondTitle service_type_title">{{ item.title }}</div>
                            <div class="service_type_btn" :id="String(item.id) + 'btn'">
                                <el-button color="#064DD6" size="large" round @click="LearnDatas(item.id)">点击查看</el-button>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="12">
                        <img :src="item.cover_image" alt="">
                    </el-col>
                </el-row>
            </swiper-slide>
            <div class="swiper-button-prev">
                <i class="iconfont icon-xiangyou21-01"></i>
            </div>
            <div class="swiper-button-next">
                <i class="iconfont icon-xiangyou-01"></i>
            </div>
        </swiper>
    </div>
</template>

<style lang="scss" scoped>
.custom-box {
    background: #fff;
    padding: 0px 30px;
    margin-top: 50px;
    border-radius: 20px;

    :deep(.swiper) {
        padding: 50px 0px !important;

        img {
            width: 100%;
            height: 100%;
            border-radius: 10px;
            padding-right: 80px;
        }
    }
}

.swiper-button-prev,
.swiper-button-next {
    width: 50px;
    height: 50px;

    &::after {
        font-size: 0px;
        background-color: #fff;
        color: #6e6e73;
        padding: 0;
        border-radius: 50px;
    }

    .iconfont {
        color: #172E59;
        font-size: 50px;
    }
}

.case-left {
    margin: 0px 120px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;

    .time {
        margin: 20px 0 10px 0;
    }

    .service_type_title {
        line-height: 2;
        margin-bottom: 40px;
    }
}
</style>